#!usr/bin/env python

import serial

s = serial.Serial('/dev/ttyUSB0', 9600)
print "Opened port " + "/dev/ttyUSB0"
print "Byte 1   |  Byte 2  | ---> |  ERRA   |   ERRB   |   MAX   |   Error   "
while s.isOpen():
	x1 = bin(ord(s.read())) 
	x2 = bin(ord(s.read())) 
	x3 = bin(ord(s.read()))
	if len(x1)==10:
		print x2 + "|" + x3 + "||" + x3[3] + "|" + x3[4] + "|" +  x3[5] + "|" + x3[6:10] + x2[2:8]

	else: 
		print x1 + "|" + x2 + "||" + x2[3] + "|" + x2[4] + "|" +  x2[5] + "|" + x2[6:10] + x1[2:8]
		 

		
